/*
 * @Author: your name
 * @Date: 2021-03-04 22:35:52
 * @LastEditTime: 2021-03-04 22:43:31
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \longan\common\my_vsprintf.h
 */

#ifndef __MY_VSPRINTF_H__
#define __MY_VSPRINTF_H__

#include "usart_drv.h"
#include "ctype.h"
#include "div64.h"
#include "my_string.h"

#ifndef my_va_arg

#ifndef _VALIST
#define _VALIST
typedef char *my_va_list;
#endif /* _VALIST */

/*
 * Storage alignment properties
 */
#define NATIVE_INT int
#define _AUPBND (sizeof(NATIVE_INT) - 1)
#define _ADNBND (sizeof(NATIVE_INT) - 1)

/*
 * Variable argument list macro definitions
 */

#define _bnd(X, bnd) (((sizeof(X)) + (bnd)) & (~(bnd)))
#define my_va_arg(ap, T) (*(T *)(((ap) += (_bnd(T, _AUPBND))) - (_bnd(T, _ADNBND))))
#define my_va_end(ap) (void)0
#define my_va_start(ap, A) (void)((ap) = (((char *)&(A)) + (_bnd(A, _AUPBND))))

#endif /* my_va_arg */

/*
 * Storage alignment properties
 */
#define NATIVE_INT int
#define _AUPBND (sizeof(NATIVE_INT) - 1)
#define _ADNBND (sizeof(NATIVE_INT) - 1)

unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base);
long simple_strtol(const char *cp, char **endp, unsigned int base);
unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base);
long long simple_strtoll(const char *cp, char **endp, unsigned int base);
//static int  skip_atoi(const char **s);
//char * number(char * buf, char * end, long long num, int base, int size, int precision, int type);
int my_vsnprintf(char *buf, size_t size, const char *fmt, my_va_list args);
int my_snprintf(char *buf, size_t size, const char *fmt, ...);
int my_vsprintf(char *buf, const char *fmt, my_va_list args);
int my_sprintf(char *buf, const char *fmt, ...);
int my_vsscanf(const char *buf, const char *fmt, my_va_list args);
int my_sscanf(const char *buf, const char *fmt, ...);

#endif
